{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "男生python最小分数为：26, 最大分数为：145, 平均分为：103.33, 中位数为：139, 标准差为54.74\n男生数学最小分数为：23, 最大分数为：76, 平均分为：55.67, 中位数为：68, 标准差为23.33\n男生语文最小分数为：60, 最大分数为：128, 平均分为：101.33, 中位数为：116, 标准差为29.63\n女生python最小分数为：34, 最大分数为：93, 平均分为：58.00, 中位数为：47, 标准差为25.31\n女生数学最小分数为：32, 最大分数为：96, 平均分为：53.33, 中位数为：32, 标准差为30.17\n女生语文最小分数为：43, 最大分数为：110, 平均分为：74.00, 中位数为：69, 标准差为27.58\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "score = np.random.randint(0, 151, size=(50, 3))\n",
    "sex = np.random.randint(0, 2, size=(50, 1))# 0 m 1 f\n",
    "i = 0\n",
    "while i < 5:\n",
    "    score = np.vstack((score, np.random.randint(0, 151, size=(50, 3))))\n",
    "    sex = np.vstack((sex, np.random.randint(0, 2, size=(50, 1))))\n",
    "    i = i+1\n",
    "\n",
    "data = np.hstack((sex,score))\n",
    "index_m = np.argwhere(data[:, 0] == 0)[:, 0]\n",
    "index_f = np.argwhere(data[:, 0] == 1)[:, 0]\n",
    "\n",
    "min_m = score[index_m].min(axis=1)\n",
    "max_m = score[index_m].max(axis=1)\n",
    "avg_m = score[index_m].mean(axis=1)\n",
    "media_m = np.median(score[index_m], axis=1)\n",
    "std_m = score[index_m].std(axis=1)\n",
    "\n",
    "min_f = score[index_f].min(axis=1)\n",
    "max_f = score[index_f].max(axis=1)\n",
    "avg_f = score[index_f].mean(axis=1)\n",
    "media_f = np.median(score[index_f], axis=1)\n",
    "std_f = score[index_f].std(axis=1)\n",
    "\n",
    "print(\"男生python最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_m[0], max_m[0],avg_m[0], media_m[0], std_m[0]))\n",
    "print(\"男生数学最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_m[1], max_m[1],avg_m[1], media_m[1], std_m[1]))\n",
    "print(\"男生语文最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_m[2], max_m[2],avg_m[2], media_m[2], std_m[2]))\n",
    "\n",
    "print(\"女生python最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_f[0], max_f[0],avg_f[0], media_f[0], std_f[0]))\n",
    "print(\"女生数学最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_f[1], max_f[1],avg_f[1], media_f[1], std_f[1]))\n",
    "print(\"女生语文最小分数为：%d, 最大分数为：%d, 平均分为：%.2f, 中位数为：%d, 标准差为%.2f\" %\n",
    "       (min_f[2], max_f[2],avg_f[2], media_f[2], std_f[2]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
